// websocketserver.cpp
#include "websocketserver/websocketserver.h"
#include "websocketserverimpl.h"

namespace hhfox
{
    WebSocketServer::WebSocketServer(const char *host, int port)
        : impl_(std::unique_ptr<WebSocketServerImpl>(new WebSocketServerImpl(host, port))) {

        }

    WebSocketServer::~WebSocketServer() {}

    void WebSocketServer::setLoggerCallback(Logger &&logger){
        impl_->setLoggerCallback(std::move(logger));
    }

    void WebSocketServer::start()
    {
        impl_->start();
    }

    void WebSocketServer::stop()
    {
        impl_->stop();
    }

    void WebSocketServer::sendRawMessage(websocketpp::connection_hdl hdl, void *buff, size_t len, msg_type op)
    {
        impl_->sendRawMessage(hdl, buff, len, op);
    }

    void WebSocketServer::sendRawMessage(websocketpp::connection_hdl hdl,const std::string& msg){
        impl_->sendRawMessage(hdl, msg);
    }

    void WebSocketServer::registerHandler(const std::string &uri, std::shared_ptr<IWebSocketHandler> handler)
    {
        impl_->registerHandler(uri, handler);
    }

    connection_ptr WebSocketServer::get_con_from_hdl(connection_hdl hdl){
        return impl_->get_con_from_hdl(hdl);
    }

}